<html>
<head>
<title>角色下的用户</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="../../build/common/base.css" rel="stylesheet">
	<script type="text/javascript" src="../../build/common/base.js"></script>
	<script type="text/javascript" src="../../build/common/gridList.js"></script>
</head>
<body class="panel-body">
	<div class="panel panel-default search-panel">
         <div class="panel-heading">查询条件
         	<a　href="javascript:void(0)" class="pull-right">　<i class="fa  fa-angle-double-up" toggle-collapse="#searchForm"></i> </a>
         </div>
         <div class="panel-body">
             <form id="searchForm" class="form-horizontal">
                 <div class="form-group">
                     <label class="control-label col-sm-1" for="fullname_^VLK">名字</label>
                     <div class="col-sm-2">
                         <input type="text" class="form-control" id="fullname_^VLK">
                     </div>
                     <div class="col-sm-2" style="text-align:left;">
                         <button type="button" style="margin-left:50px" class="btn btn-primary fa-search">查询</button>
                     </div>
                 </div>
             </form>
         </div>
     </div>
	 <div class="btn-group toolbar">
		  <button class="btn btn-outline btn-primary fa-plus" onclick="addUser()">新增 </button>
		  <a class="btn btn-outline btn-primary fa-back" onClick="javascript:$.Dialog.close(window);"><span>返回</span></a>
     </div>
	 <table ab-grid data-id-field="id" data-url="/org/orgRelation/roleJson?roleId={roleId}">
         <thead>
         <tr>
             <th data-checkbox="true">ID</th>
             <th data-field="userName">用户名</th>
             <th data-field="userAccount">用户账户</th>
             <th data-field="roleName" >角色名</th>
             <th data-field="updateTime" >操作时间</th>
             <th data-field="id" data-formatter="innerHtmlFormatter" data-title="管理">
				<a if="'{type}'!='groupUserRole'" class='btn btn-outline btn-danger fa  fa-trash' sendAction='删除' qtip='删除' url='/org/orgRelation/remove?id={id}'></a>
				<a if="'{type}'=='groupUserRole'" class='btn btn-outline btn-default fa fa-trash' qtip="当前用户角色关系为组织【{groupName}】下岗位，需要从该组织下移除该用户的职务"></a>
             </th>
         </tr>
         </thead>
     </table>
</body>
</html>
<script>
var roleId = $.getParam("roleId");
	function addUser() {
		CustUtil.openCustDialog("userSelector",function(arrData,innerWindow){
 			var ids = [];
 			for(var i=0,user;user=arrData[i++];){
 				ids.push(user.id);
 			}
 			
 			$.post(__ctx + "/org/orgRelation/saveRoleUsers",{userIds:ids.join(","),roleId:roleId},function(data){
				 data = JSON.parse(data);
				 reloadGrid();
				 if(data.isOk){
					$.Dialog.success(data.msg);
 		   			$.Dialog.close(innerWindow);
				 }else{
					 $.Dialog.error("操作失败"+data.msg);
				 }
			 })
 			
 		})
	}
</script>
